<?php

// +----------------------------------------------------------------------
// | 发票数据表
// +----------------------------------------------------------------------

namespace common\model;

use think\model\RelationModel;

class InvoiceModel extends RelationModel
{

    //自动验证
    protected $_validate = [
        ['order_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['receivable_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT], //必须字段
        ['attached_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT], //必须字段
        ['confirm_receipt', ['yes', 'no'], '', self::EXISTS_VALIDATE, 'in']

    ];

    //自动完成
    protected $_auto = [
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
//        ['uuid', 'create_uuid', self::MODEL_INSERT, 'function']
    ];

    /**
     * 获取器：创建时间
     * @param $value
     * @param $data
     * @return array|mixed
     */
//    public function getCreatedAttr($value, $data)
//    {
//        if (!empty($value)) {
//            return get_format_date($value, 1);
//        }
//        return "";
//    }
}
